home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / usr / bin / linux-boot-prober < prev    next >
Text File  |  2008-08-25  |  1KB  |  52 lines

  1. #!/bin/sh
  2. . /usr/share/os-prober/common.sh
  3.  
  4. set -e
  5.  
  6. require_tmpdir
  7.  
  8. grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true
  9.  
  10. partition="$1"
  11. if ! mapped="$(mapdevfs "$partition")"; then
  12.     log "Device '$partition' does not exist; skipping"
  13.     continue
  14. fi
  15.  
  16. if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map"; then
  17.     for test in /usr/lib/linux-boot-probes/*; do
  18.         debug "running $test"
  19.         if [ -x $test ] && [ -f $test ]; then
  20.             if $test $partition; then
  21.                 debug "linux detected by $test"
  22.                 break
  23.             fi
  24.         fi
  25.     done
  26. else
  27.     mpoint=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 2)
  28.     if [ "$mpoint" != "/target/boot" ] && [ "$mpoint" != "/target" ] && [ "$mpoint" != "/" ]; then
  29.         type=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 3)
  30.         if ! grep -q " $mpoint/boot " "$OS_PROBER_TMP/mounted-map"; then
  31.             mountboot="$(linux_mount_boot "$partition" "$mpoint")"
  32.             bootpart="${mountboot%% *}"
  33.             bootmounted="${mountboot#* }"
  34.         else
  35.             bootpart="$partition"
  36.             bootmounted=0
  37.         fi
  38.         for test in /usr/lib/linux-boot-probes/mounted/*; do
  39.             if [ -f $test ] && [ -x $test ]; then
  40.                 debug "running $test on mounted $partition"
  41.                 if $test $partition $bootpart $mpoint $type; then
  42.                     debug "$test succeeded"
  43.                     break
  44.                 fi
  45.             fi
  46.         done
  47.         if [ "$bootmounted" = 1 ]; then
  48.             repeat_umount $mpoint/boot || true
  49.         fi
  50.     fi
  51. fi
  52.